home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Office / ToDo List ƒ / ToDo List 2.1 Manual / ToDo List 2.1 Manual.rsrc / TEXT_134.txt < prev    next >
Text File  |  1997-02-05  |  9KB  |  181 lines

  1. Scripting ToDo List
  2.  
  3. The ToDo List application is fully scriptable ‚Äì anything that you can do to a document using the keyboard and mouse, can be done by a script using the AppleEvents supported by ToDo List.  Using AppleScript (which is available for free on every Macintosh), you can create powerful custom solutions that combine the features of ToDo List with other scriptable applications.  For example, you might already be using ToDo List as a convenient place to keep a list of files you plan to download from Info-Mac.  With a simple script, you could automatically iterate through all of the items in the list and for each, use Anarchie (which is also scriptable) to download the file to your machine.
  4.  This chapter provides an overview of the elements in ToDo List that you can control, and the commands that are available to control them.  It assumes that you already have some familiarity with AppleScript.
  5.  
  6. The ToDo List Elements
  7. Scriptable applications are typically made up of a variety of elements that can be specified (the 5th item of the document "Stuff")  and a set of actions that can be performed on those elements.  ToDo List provides a hierarchy of element types and a variety of ways to refer to them.
  8. At the top of the hierarchy is a single application.  The application has a number of properties (that correspond to the current preferences) that can be addressed directly:
  9.     autoOpen  boolean  -- should ToDo List automatically open your last documents when launched
  10.     confirmDelete  boolean  -- confirm deletes
  11.     play toggle sound  boolean  -- play sound when toggling items
  12.     saveOnClose  boolean  -- automatically save documents on close
  13.     saveInterval  integer  -- save documents after this number of minutes (0 = don't auto-save)
  14.     returnKeyClicksOK  boolean  -- <return> same as hitting OK in item dialog
  15. You can retrieve or change any of these properties using AppleScript:
  16. set areWeAutoOpening to the autoOpen of application "ToDo List"
  17. set the autoOpen of application "ToDo List" to true
  18.  
  19. The application also contains some number of document elements (one for each ToDo List document).  You can refer to the documents by name or by index:
  20.  
  21. document "Things To Do" of application "ToDo List"
  22. document 3 of application "ToDo List"
  23.  
  24. Each document has several properties that can be addressed directly:
  25.     name  string  -- the title of the document
  26.     show calendar  boolean  -- should the calendar be shown across the top of the document
  27.     use dates  boolean  -- should all items have a due date associated with them
  28.     show overdue  boolean  -- show how many days each item is overdue
  29.     carryforward unfinished  boolean  -- should unfinished items be carried forward
  30.     date font  string  -- font to use for displaying dates
  31.     date size  integer  -- size of font for displaying dates
  32.     item font  string  -- font for displaying items
  33.     item size  integer  -- font size for displaying items
  34.     clipboard text only  boolean  -- should copying to the clipboard copy only text
  35.     voice  string  -- voice that should be used for speaking items
  36.     useSmallCalendarFont  boolean  -- if true, then a very small font is used for calendar
  37.  
  38. You can change these properties using AppleScript:
  39.  
  40. tell application "ToDo List"
  41.    set the date font of document "Important Stuff" to "Times"
  42.    set the show overdue of document 4 to false
  43. end tell
  44.  
  45. Documents also contain some number of item elements.  These elements can be accessed by index:
  46. item 5 of document 4
  47.  
  48. If the list is using due dates, then items can also be accessed via the date:
  49. item 3 of date "1/13/96" of document 4
  50. item 6 of date "June 1, 1996" of document "Stuff"
  51.  
  52. Each item has a number of properties that you can retrieve or set:
  53.     uniqueID  integer  [r/o]  -- a unique ID for the to do item
  54.     description  string  -- the text of the to do item
  55.     dueDate  string  -- the date the item should be done on
  56.     completed  boolean  -- has the item been completed (true or false)
  57.     created  string  [r/o]  -- date and time that the item was created
  58.     priority  integer  -- priority of the item (0 - 10, 0 = none, 1 = highest)
  59.     modified  string  [r/o]  -- date and time that the item was last modified
  60.     selected  boolean  -- true if the item is currently selected
  61. You can access these properties from AppleScript by just fully specifying the item and property.  For example: 
  62. tell application "ToDo List"
  63.    -- Check off an item as finished
  64.    set the completed of item 4 of document "Important Stuff" to true
  65.    -- Change the due date of an item
  66.    set the dueDate of item 2 of date "5/16/96" of
  67.                 document 3 to "May 20, 1996"
  68. end tell
  69.  
  70. You can create new elements using the make command.
  71.  
  72. AppleScript Commands
  73. ToDo List supports the standard open, print, and quit AppleEvents, so you can easily get it to launch and open a set of ToDo List documents.  It also lets you save and close documents as needed:
  74.  
  75. save: save the document to disk
  76.     save  document
  77.         [in  alias]  -- file to save the document in
  78.  
  79.  
  80. close: close the document's window
  81.     close  document  -- document to close
  82.         [saving  yes/no/ask]  -- should any changes be saved
  83.         [saving in  alias]  -- file to save the document in
  84.  
  85. For example:
  86. tell application "ToDo List"
  87.    open alias "My Harddisk:Lists:Stuff To Do"
  88.    set the voice of document "Stuff To Do" to "Victoria"
  89.    save document "Stuff To Do"
  90.    close document "Stuff To Do"
  91. end tell
  92.  
  93. ToDo List also supports several core AppleEvents that let you count, create, delete, etc. the various elements that it defines:
  94.  
  95. count: count the number of elements in a class
  96. count  reference  -- the object whose elements are to be counted 
  97.     each  type class  -- the class of the elements to be counted.  
  98. Result:   integer  -- the number of elements in the given class
  99. For example:
  100. tell application "ToDo List"
  101.    set cnt to count of documents
  102.    set numItems to count of item of document 3
  103.    set dayItems to count each item of date "5/6/96" of document "Stuff"
  104.    set numDates to count each date of document 1
  105. end tell
  106.  
  107.  
  108. get: get data for a to do item
  109. get  reference  -- reference to the item to get
  110. Result:   anything  -- data for the requested to do item
  111.  
  112.  
  113. set: set an item or property of an item to some value
  114. set  reference  -- the item or item property to change
  115.     to  anything  -- new value for the item or property
  116.  
  117.  
  118. make: make a new item
  119.     make
  120.         new  type class
  121.         [at  integer]
  122.         with properties  record
  123.         within  reference  -- the document to which the new item should be added
  124.     Result:   integer  -- index of the new item
  125. Makes a new item of the given type ("item" or "document").  Any unspecified properties default to the same values as they would if the item were created directly in ToDo List.  For example:
  126. tell application "ToDo List"
  127.    -- Note: make new document doesn't support 'with properties'!
  128.    set docNum to make new document
  129.    set docName to get name of document docNum
  130.    set the use dates of document docName to true
  131.    make new item at 1 within document docName
  132.        with properties { description:"testing", priority: 1,
  133.                         dueDate:"Feb 1, 1996"}
  134.    make new item at 9999 within document docName
  135.        with properties { description:"testing", priority: 0,
  136.                         completed: true, dueDate:"Feb 1, 1996"}
  137. end tell
  138.  
  139.  
  140. delete: delete an item from the document
  141.     delete  reference  -- the item to delete 
  142.   For example:
  143. tell application "ToDo List"
  144.    delete item 1 of document "Stuff"
  145.    delete item 1 of date "5/5/96" of document 2
  146. end tell
  147.  
  148. move: move the referenced item to a new location, changing its due date and priority if necessary
  149.     move  reference  -- a reference to the item to be moved
  150.         to  integer  -- index of the location the item should be moved to
  151. Moves an item from one location to anotherwithin the same document.  If necessary, the priority or due date of the item will be modified to match the new location.  For example:
  152. tell application "ToDo List"
  153.    -- Move the first item to the end of the list
  154.    move item 1 of document "Stuff" to 9999
  155.    -- Swap the first and second items
  156.    move item 1 of document "Stuff" to 2
  157. end tell
  158.  
  159. ToDo List also supports several custom AppleEvents that let you control the special features of the application:
  160.  
  161. SpeakItems: Read all of the unfinished items in the list
  162. SpeakItems  document  -- the ToDo List document to speak items from
  163.  
  164. SpeakTodaysItems: Read all of the unfinished items for today
  165. SpeakTodaysItems  document  -- the ToDo List document to read today's items from 
  166.  
  167. synchronizeNewton: synchronize the given document with a Newton
  168. synchronizeNewton  document  -- the ToDo List document to synchronize to
  169.     [via  serial-modem/serial-printer/modem/AppleTalk]
  170.         -- synchronize Newton using this connection (serial, AppleTalk, modem)
  171.     [using  string]  -- option string for the connection
  172.  
  173. export: export the selected items (or all if none are selected) in the given ToDo List document to a tab-delimited text file.
  174. export  document  -- the ToDo List document to export to a text file
  175.     [as  text/HTML]  -- type of document to create (text or HTML).
  176.     [in  alias]  -- the file to export the ToDo List document into
  177.  
  178. import: import items from a tab-delimited text file
  179. import  document  -- the ToDo List document to import the items into
  180.     [from  alias]  -- the tab-delimited text file to import the items from
  181.